package com.learn.security.oauth2.auth.server.service.db.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.learn.security.oauth2.auth.server.service.db.mapper.SysUserMapper;
import com.learn.security.oauth2.auth.server.service.db.service.ISysUserService;
import com.learn.security.oauth2.orm.SysUser;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户信息 服务实现类
 * </p>
 *
 * @author knight
 * @since 2021-11-23
 */
@Service
@RequiredArgsConstructor
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {

	@Override
	public SysUser selectUserByUsername(String phone) {
		LambdaQueryWrapper<SysUser> queryWrapper = Wrappers.<SysUser>lambdaQuery()
				// 根据用户名过滤
				.eq(SysUser::getSuUsername, phone).last("limit 1");
		return this.getOne(queryWrapper);
	}

}
